
#ifndef FILEDIALOG_H
#define FILEDIALOG_H

#include <BPainter>
#include <BMenu>
#include <BComboBox>
#include <BHBoxLayout>
#include <BFileDialog>

using namespace BWE;

class PathButton : public BButton
{
	BOBJECT(PathButton);
public:
	PathButton(BWidget* parent = 0) : BButton(parent)
	{
		this->setMargin(Part_Left, 6);
		this->setPerch(Part_Right, 12);
	}

	virtual BSize sizeHint() const
	{
		return BButton::sizeHint();
	}

protected:
	virtual void paintEvent(const BEvent& event)
	{
		BButton::paintEvent(event);
		if (this->icon() || this->image() || this->graph())
			return;
		BPainter painter(this);
		painter.setColor(Color_Text);
		BRect rightRect = this->rect(Part_Right).align(Align_Center, BSize(5, 10));
		painter.drawGraph(rightRect, Graph_Arrow_Right_Fill);
	}
};

class FileDialog : public BFileDialog
{
public:
	FileDialog(BWidget* parent = 0);
	~FileDialog();

protected:
	void freshButtons();

protected:
	void slotPathTextChanged(BObject* object, const BValue& value);
	void slotPathWidgetFocused(BObject* object, const BValue& value);
	void slotPathComboBoxFresh(BObject* object, const BValue& value);
	void slotPathButtonClicked(BObject* object, const BValue& value);
	void slotTreeWidgetRightClicked(BObject* object, const BValue& value);
	void slotTableWidgetRightClicked(BObject* object, const BValue& value);

protected:
	virtual void styleEvent(const BEvent& event);

private:
	BComboBox*		_pathComboBox;
	BHBoxLayout*	_buttonLayout;
	BMenuHolder		_menu;
};

#endif
